﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SF.Base.Core;

namespace SF.Dict.Web {
	public partial class Comment : BasePage {

		protected void Page_Load(object sender, EventArgs e) {
			long Vid = Request.GetLong("vid");
			string VocabularyId = VocabularyRules.GetStrId(Vid);

			string Initial = Request.GetStr("index");
			if (Global.DTUser == null) {
				Response.Redirect("/login.aspx?return=" + Server.UrlEncode(string.Format("/Comment.aspx?vid={0}&index={1}", Vid, Initial)));
			}

			if( !Page.IsPostBack ){

				ucVocHeader1.VocabularyId = VocabularyId;
				ucVocAside1.VocabularyId = VocabularyId;
				ucVocHeader1.PageName = "comment";
				ucVocHeader1.Initial = Initial;
				ll_title.Text = "评论&笔记 | 挚友云海";

				VocabularyEntity voc = VocabularyRules.GetVocabulary(Vid);

				if(voc == null){
					//错误处理
					return;
				}

				//查询词汇表下全部心得
				List<CommentEntity> lists = CommentRules.GetDictCommentsByVocabularyId(voc.VocabularyId, UserId);
				
				rp_comments.DataSource = lists;
				rp_comments.DataBind();

			}
		}
	}
}